<!DOCTYPE html>
<script src="js/baidu-tongji.js"></script>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>载入存档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
    <link rel="stylesheet" type="text/css" href="baye.css" />
    <script src="js/lzma_worker-min.js"></script>
    <script src="js/base64.js"></script>
</head>
<body>
<script>
(function() {
    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }

    function filename(n) {
        return "baye//data//sango" + n + ".sav";
    }

    function load(n, hex) {
        var tuple = hex.split(".");
        localStorage[filename(n*3)] = tuple[0];
        localStorage[filename(n*3+1)] = tuple[1];
    }

    var data = getParameterByName("sav", window.location.href);
    var name = getParameterByName("name", window.location.href);
    data = data.replace(/ /g, "+");
    var lzma = Base64.decode(data);
    var hex = LZMA.decompress(lzma);
    load(2, hex);
    document.write("<br>");
    document.write("已载入到第4个存档位<br>");
    if (name && name.length) {
        document.write("请使用'" + name + "'载入存档");
    }
})();
</script>

<button class="btn menu" type="button" onclick="location='index.html';">返回游戏</button>

</body>
</html>